<?php


namespace api\app\controller;


use api\app\model\GoodsModel;
use cmf\controller\RestBaseController;

class GoodsController extends  RestBaseController
{
    public function getGoodsInfo()
    {
        $goods_id = input('goods_id/d');
        if (empty($goods_id)) {
            $this->error('参数错误');
        }
        $goods = GoodsModel::find($goods_id);
        unset($goods['info']);
        $goodsAttr=json_decode($goods['attr'],true);
        if (!$goods) {
            $this->error('商品不存在');
        }
        foreach($goodsAttr as $key => $val) {
            $goodsAttr[$key]['attr_value']=explode(',',$val['attr_value']);
        }

        return success('返回成功',$goods);
    }

}